export function renderContext(instance, setupState) {
  return new Proxy(instance, {
    get(target, key) {
      const {state, props} = target
      if(state &&  key in state) {
        return state[key]
      } else if(key in props) {
        return props[key]
      } else if(setupState && key in setupState) {
        return setupState[key]
      } else if(key === '$slots') {
        return instance.slots
      } else {
        console.error(`this.${key}不存在`)
      }
    },
    set(target, key, newValue) {
      const {state, props} = target
      if(state && key in state) {
        state[key] = newValue
      } else  if(key in props) {
        console.warn(`尝试修改props${key}, props 是只读的`)
      } else {
        console.error(`this.${key}不存在`)
      }
    }
  })
}
